<?php
require("config.php");

$config = array(
    "digest_alg" => "sha512",
    "private_key_bits" => 1024,
    "private_key_type" => OPENSSL_KEYTYPE_RSA,
);
   
$res = openssl_pkey_new($config);
openssl_pkey_export($res, $privKey);
$pubKey = openssl_pkey_get_details($res);
$pubKey = $pubKey["key"];

$data = 'plaintext data goes here';


//openssl_public_encrypt($data, $encrypted, $pubKey);



//openssl_private_decrypt($encrypted, $decrypted, $privKey);
$user=mysql_real_escape_string($_GET['user']);
$query=mysql_query("INSERT INTO rsa_keys VALUES('{$user}','{$pubKey}','{$privKey}')");


echo $pubKey;
?>